#include<bits/stdc++.h>
using namespace std;
#define lup(var,start,end) for(long long var=start;var<=end;var++)
#define ldn(var,start,end) for(long long var=start;var>=end;var--)
typedef long long ll;
typedef long double dl;
ll read(void);
void write(ll);
void init(void);
inline int dcm(dl aw,dl bw)
{
    if(fabs(aw-bw)<=1e-14)return 0;
    else if(aw>bw)return 1;
    else return -1;
}
inline dl Vi(ll sv,ll ss,ll sa)
{
    return sqrt(dl(sv*sv+2*sa*ss));
}
inline dl Si(ll sv,ll nv,ll sa)
{
    return dl(nv*nv-sv*sv)/dl(2*sa);
}
ll T,n,m,L,V,cnt1,cnt2,sp1,sp2,sp3;
ll d[100005],v[100005],a[100005],p[100005],car[100005];
int main()
{
    freopen("detect5.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--)
    {
        init();
        lup(i,1,n)
        {
            if(!sp1)
            {
                if(v[i]>V)
                {
                    cnt1++;
                    cnt2=1;
                }
            }
            else if(!sp2)
            {
                if(m==0);
                else if(dcm(Vi(v[i],p[m]-d[i],a[i]),(dl)V)>0)
                {
                    if(p[m]>=d[i])cnt1++;
                    cnt2=1;
                }
            }
            else if(!sp3)
            {
                ll k=1,f=1;
                if(m==0);
                else if(f&&dcm(Vi(v[i],d[i],a[i]),(dl)V)>0)
                {
                    cnt1++;
                    cnt2=1;
                }
            }
        }
        write(cnt1);
        putchar(' ');
        write(m-cnt2);
        putchar('\n');
        cnt1=cnt2=sp1=sp2=sp3=0;
    }
    return 0;
}
inline ll read(void)
{
    char ch=getchar();
    int input_sign=1;
    ll input_result=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')input_sign=-1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        input_result=(input_result<<1)+(input_result<<3);
        input_result+=ch^48;
        ch=getchar();
    }
    return input_sign*input_result;
}
inline void write(ll output_value)
{
    if(output_value<0)
    {
        output_value=0-output_value;
        putchar('-');
    }
    if(output_value==0)
    {
        putchar('0');
        return;
    }
    int output_digit[40],output_len=0;
    while(output_value>0)
    {
        output_digit[++output_len]=(output_value%10)^48;
        output_value/=10;
    }
    for(int i=output_len; i>=1; i--)putchar(output_digit[i]);
}
void init(void)
{
    n=read();
    m=read();
    L=read();
    V=read();
    lup(i,1,n)
    {
        d[i]=read();
        v[i]=read();
        a[i]=read();
        if(a[i]!=0)sp1=1;
        if(a[i]<0)sp2=1;
        if(a[i]>0)sp3=1;
    }
    lup(i,1,m)
    {
        p[i]=read();
    }
}
